<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>register</title>
  <link rel="stylesheet" href="./css/loading.css">
  <link rel="stylesheet" href="./css/element-ui.css">
  <link rel="stylesheet" href="./css/login.css">
</head>
<body>
  <div id="appLoading">
   <img src="./images/loading.gif" width="50px" height="50px">
   <div class="loading-text">加载中......</div>
  </div>
  <div id="register" style="display:none">
    <div class="aver"></div>
    <el-input
      placeholder="请输入邮箱地址"
      type="mail"
      @blur="AboutMail"
      v-model="mail">
      <img slot="prefix" class="log-user" src="./images/icon/mail.png"></img>
    </el-input>
    <div class="sign" v-if="Ismail">邮箱格式不正确</div>
    <el-input
      placeholder="请输入密码"
      type="password"
      v-model="passwd">
      <img slot="prefix" class="log-passwd" src="./images/icon/ts-lock.png"></img>
    </el-input>
    <el-input
      placeholder="请确认密码"
      type="password"
      @blur="AboutPasswd"
      v-model="repasswd">
      <img slot="prefix" class="log-passwd" src="./images/icon/ts-lock.png"></img>
    </el-input>
    <div class="sign" v-if="IsPass">两次输入密码不相同</div>
    <el-button type="primary" v-on:click="SubmitIt">注册</el-button>
  </div>
</body>
  <script src="./js/vue.min.js"></script>
  <script src="./js/element-ui.js"></script>
  <script src="./js/axios.min.js"></script>
  <script type="text/javascript">
    new Vue({
      el: "#register",
      data: function() {
        return {
          mail: "",
          passwd: "",
          repasswd: "",
          Ismail: false,
          IsPass: false
        }
      },
      methods: {
        AboutMail: function(){
          console.log("89898");
          let regEmail= /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/
          if (!regEmail.test(this.mail)) {
            this.Ismail=true;
            console.log("no");
          } else {
            this.Ismail=false;
            console.log('yes');
          }
        },
        AboutPasswd: function(){
          if (this.passwd != this.repasswd) {
            this.IsPass = true;
          } else {
            this.IsPass = false;
          }
        },
        SubmitIt: function() {
          console.log("890");
          if (this.IsPass || this.Ismail) {
            alert("no");
          } else if (this.mail=="" || this.passwd=="") {
            alert("null");
          }
        }
      },
      mounted(){
       document.getElementById('register').style.display = 'block';
       document.getElementById('appLoading').style.display = 'none';
      }
    })
  </script>
</html>
